<template>
  <div class="color-extractor">
    <div class="container">
      <header class="tool-header">
        <h1>颜色提取器工具</h1>
        <p class="subtitle">从图片中提取颜色 palette，支持多种颜色格式</p>
      </header>

      <div class="tool-content">
        <!-- 上传区域 -->
        <div class="upload-section">
          <div
            class="upload-area"
            @click="triggerFileInput"
            @drop="handleDrop"
            @dragover.prevent
            :class="{ dragover: isDragover, 'has-image': !!imagePreview }"
          >
            <input
              type="file"
              ref="fileInput"
              @change="handleFileSelect"
              accept="image/*"
              style="display: none"
            />
            <div class="upload-icon">
              <span v-if="!imagePreview">🖼️</span>
              <img v-else :src="imagePreview" alt="预览图片" class="preview-image" />
            </div>
            <p v-if="!imagePreview">点击选择图片或拖拽图片到这里</p>
            <p v-else class="image-info">已选择图片 {{ imageName }}</p>
            <small>支持 JPG、PNG、WebP 格式，最大 5MB</small>
          </div>

          <div v-if="imagePreview" class="upload-actions">
            <button @click="extractColors" class="extract-btn" :disabled="isExtracting">
              {{ isExtracting ? '提取中...' : '🎨 提取颜色' }}
            </button>
            <button @click="clearImage" class="clear-btn">清除图片</button>
          </div>
        </div>

        <!-- 提取选项 -->
        <div v-if="imagePreview" class="options-section">
          <h3>提取设置</h3>
          <div class="options-grid">
            <div class="option-group">
              <label>颜色数量：</label>
              <div class="slider-container">
                <input
                  type="range"
                  v-model="extractOptions.colorCount"
                  min="3"
                  max="20"
                  step="1"
                  class="count-slider"
                />
                <span class="slider-value">{{ extractOptions.colorCount }} 种</span>
              </div>
            </div>

            <div class="option-group">
              <label>提取精度：</label>
              <select v-model="extractOptions.quality">
                <option value="high">高精度（慢）</option>
                <option value="medium">中等精度</option>
                <option value="low">低精度（快）</option>
              </select>
            </div>

            <div class="option-group">
              <label>颜色分组：</label>
              <select v-model="extractOptions.grouping">
                <option value="auto">自动分组</option>
                <option value="strict">严格分组</option>
                <option value="loose">宽松分组</option>
              </select>
            </div>

            <div class="option-group">
              <label class="checkbox-label">
                <input type="checkbox" v-model="extractOptions.includeHex" />
                <span class="checkmark"></span>
                包含HEX格式
              </label>
            </div>

            <div class="option-group">
              <label class="checkbox-label">
                <input type="checkbox" v-model="extractOptions.includeRgb" />
                <span class="checkmark"></span>
                包含RGB格式
              </label>
            </div>

            <div class="option-group">
              <label class="checkbox-label">
                <input type="checkbox" v-model="extractOptions.includeHsl" />
                <span class="checkmark"></span>
                包含HSL格式
              </label>
            </div>
          </div>
        </div>

        <!-- 颜色展示 -->
        <div v-if="extractedColors.length > 0" class="colors-section">
          <div class="section-header">
            <h3>提取的颜色 Palette</h3>
            <div class="header-actions">
              <button @click="copyAllColors" class="copy-btn">
                {{ copyButtonText }}
              </button>
              <button @click="exportPalette" class="export-btn">导出 Palette</button>
            </div>
          </div>

          <div class="colors-grid">
            <div
              v-for="(color, index) in extractedColors"
              :key="index"
              class="color-item"
              :style="{ backgroundColor: color.hex }"
              @click="selectColor(color)"
              :class="{ selected: selectedColorIndex === index }"
            >
              <div class="color-info">
                <div class="color-hex">{{ color.hex }}</div>
                <div class="color-percentage">{{ color.percentage }}%</div>
              </div>
              <div class="color-details" v-if="selectedColorIndex === index">
                <div class="color-format" v-if="extractOptions.includeRgb">
                  RGB: {{ color.rgb }}
                </div>
                <div class="color-format" v-if="extractOptions.includeHsl">
                  HSL: {{ color.hsl }}
                </div>
                <div class="color-actions">
                  <button @click.stop="copyColor(color)" class="color-copy-btn">复制</button>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 颜色详情 -->
        <div v-if="selectedColor" class="color-detail-section">
          <h3>颜色详情</h3>
          <div class="detail-content">
            <div class="color-preview" :style="{ backgroundColor: selectedColor.hex }"></div>
            <div class="color-properties">
              <div class="property-group">
                <div class="property">
                  <span class="property-label">HEX:</span>
                  <span class="property-value">{{ selectedColor.hex }}</span>
                </div>
                <div class="property" v-if="extractOptions.includeRgb">
                  <span class="property-label">RGB:</span>
                  <span class="property-value">{{ selectedColor.rgb }}</span>
                </div>
                <div class="property" v-if="extractOptions.includeHsl">
                  <span class="property-label">HSL:</span>
                  <span class="property-value">{{ selectedColor.hsl }}</span>
                </div>
              </div>

              <div class="color-similar">
                <h4>相似颜色</h4>
                <div class="similar-colors">
                  <div
                    v-for="similar in similarColors"
                    :key="similar.hex"
                    class="similar-color"
                    :style="{ backgroundColor: similar.hex }"
                    @click="selectSimilarColor(similar)"
                  >
                    <span class="similar-hex">{{ similar.hex }}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 调色板工具 -->
        <div v-if="extractedColors.length > 0" class="palette-tools">
          <h3>调色板工具</h3>
          <div class="tools-grid">
            <div class="tool-item">
              <button @click="generateShades" class="tool-btn">生成色阶</button>
              <small>为选中的颜色生成明暗变化</small>
            </div>
            <div class="tool-item">
              <button @click="analyzeContrast" class="tool-btn">对比度分析</button>
              <small>分析颜色之间的对比度</small>
            </div>
            <div class="tool-item">
              <button @click="sortColors" class="tool-btn">排序颜色</button>
              <small>按亮度或色相排序</small>
            </div>
            <div class="tool-item">
              <button @click="savePalette" class="tool-btn">保存调色板</button>
              <small>保存到本地存储</small>
            </div>
          </div>
        </div>

        <!-- 使用建议 -->
        <div v-if="extractedColors.length > 0" class="suggestions-section">
          <h3>使用建议</h3>
          <div class="suggestions-grid">
            <div class="suggestion-item">
              <div class="suggestion-title">主色调</div>
              <div class="suggestion-colors">
                <div
                  v-for="color in mainColors"
                  :key="color.hex"
                  class="suggestion-color"
                  :style="{ backgroundColor: color.hex }"
                ></div>
              </div>
              <p>适合作为品牌主色和重要元素</p>
            </div>
            <div class="suggestion-item">
              <div class="suggestion-title">辅助色</div>
              <div class="suggestion-colors">
                <div
                  v-for="color in accentColors"
                  :key="color.hex"
                  class="suggestion-color"
                  :style="{ backgroundColor: color.hex }"
                ></div>
              </div>
              <p>用于按钮、链接等交互元素</p>
            </div>
            <div class="suggestion-item">
              <div class="suggestion-title">中性色</div>
              <div class="suggestion-colors">
                <div
                  v-for="color in neutralColors"
                  :key="color.hex"
                  class="suggestion-color"
                  :style="{ backgroundColor: color.hex }"
                ></div>
              </div>
              <p>用于背景、边框等中性元素</p>
            </div>
          </div>
        </div>

        <!-- 信息说明 -->
        <div class="info-section">
          <h3>颜色提取说明</h3>
          <p>
            颜色提取器使用算法分析图片中的主要颜色，生成协调的调色板。提取的颜色可以用于网页设计、品牌设计、UI设计等场景。
          </p>
        </div>
      </div>

      <footer class="tool-footer">
        <p>© 2023 Vue 3 颜色提取器工具</p>
      </footer>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, watch } from 'vue'

// 响应式数据
const fileInput = ref(null)
const imagePreview = ref('')
const imageName = ref('')
const isExtracting = ref(false)
const isDragover = ref(false)
const extractedColors = ref([])
const selectedColorIndex = ref(-1)
const copyButtonText = ref('复制所有颜色')
const colorShades = ref([])

// 提取选项
const extractOptions = ref({
  colorCount: 8,
  quality: 'medium',
  grouping: 'auto',
  includeHex: true,
  includeRgb: true,
  includeHsl: true
})

// 触发文件选择
const triggerFileInput = () => {
  fileInput.value?.click()
}

// 处理文件选择
const handleFileSelect = (event) => {
  const file = event.target.files[0]
  if (file) {
    loadImage(file)
  }
}

// 处理拖拽
const handleDrop = (event) => {
  event.preventDefault()
  isDragover.value = false
  const file = event.dataTransfer.files[0]
  if (file && file.type.startsWith('image/')) {
    loadImage(file)
  }
}

// 加载图片
const loadImage = (file) => {
  if (file.size > 5 * 1024 * 1024) {
    alert('图片大小不能超过5MB')
    return
  }

  const reader = new FileReader()
  reader.onload = (e) => {
    imagePreview.value = e.target.result
    imageName.value = file.name
  }
  reader.readAsDataURL(file)
}

// 提取颜色
const extractColors = async () => {
  if (!imagePreview.value) return

  isExtracting.value = true
  extractedColors.value = []
  selectedColorIndex.value = -1

  try {
    // 模拟颜色提取过程（实际项目中可以使用颜色提取库）
    await new Promise(resolve => setTimeout(resolve, 1000))

    // 生成模拟颜色数据
    const colors = generateSampleColors(extractOptions.value.colorCount)
    extractedColors.value = colors

    // 自动选择第一个颜色
    if (colors.length > 0) {
      selectedColorIndex.value = 0
    }
  } catch (error) {
    console.error('颜色提取失败:', error)
  } finally {
    isExtracting.value = false
  }
}

// 生成示例颜色（实际项目中替换为真实的颜色提取算法）
const generateSampleColors = (count) => {
  const colors = []
  const baseHues = [0, 30, 60, 120, 180, 240, 300] // 常见色相

  for (let i = 0; i < count; i++) {
    const hue = baseHues[i % baseHues.length] + Math.random() * 30 - 15
    const saturation = 60 + Math.random() * 30
    const lightness = 40 + Math.random() * 30
    const percentage = (100 / count) + (Math.random() * 10 - 5)

    const hex = hslToHex(hue, saturation, lightness)
    const rgb = hslToRgb(hue, saturation, lightness)
    const hsl = `hsl(${Math.round(hue)}, ${Math.round(saturation)}%, ${Math.round(lightness)}%)`

    colors.push({
      hex,
      rgb,
      hsl,
      percentage: Math.round(percentage * 10) / 10,
      hue,
      saturation,
      lightness
    })
  }

  // 按百分比排序
  return colors.sort((a, b) => b.percentage - a.percentage)
}

// HSL转HEX
const hslToHex = (h, s, l) => {
  const rgb = hslToRgb(h, s, l)
  return `#${rgb.r.toString(16).padStart(2, '0')}${rgb.g.toString(16).padStart(2, '0')}${rgb.b.toString(16).padStart(2, '0')}`
}

// HSL转RGB
const hslToRgb = (h, s, l) => {
  h /= 360
  s /= 100
  l /= 100

  let r, g, b

  if (s === 0) {
    r = g = b = l
  } else {
    const hue2rgb = (p, q, t) => {
      if (t < 0) t += 1
      if (t > 1) t -= 1
      if (t < 1 / 6) return p + (q - p) * 6 * t
      if (t < 1 / 2) return q
      if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6
      return p
    }

    const q = l < 0.5 ? l * (1 + s) : l + s - l * s
    const p = 2 * l - q

    r = hue2rgb(p, q, h + 1 / 3)
    g = hue2rgb(p, q, h)
    b = hue2rgb(p, q, h - 1 / 3)
  }

  return {
    r: Math.round(r * 255),
    g: Math.round(g * 255),
    b: Math.round(b * 255)
  }
}

// 选择颜色
const selectColor = (color) => {
  const index = extractedColors.value.findIndex(c => c.hex === color.hex)
  selectedColorIndex.value = index
}

// 选中的颜色
const selectedColor = computed(() => {
  return selectedColorIndex.value >= 0 ? extractedColors.value[selectedColorIndex.value] : null
})

// 相似颜色
const similarColors = computed(() => {
  if (!selectedColor.value) return []

  return extractedColors.value
    .filter(color => color.hex !== selectedColor.value.hex)
    .slice(0, 3)
    .map(color => ({
      ...color,
      similarity: calculateColorSimilarity(selectedColor.value, color)
    }))
    .sort((a, b) => b.similarity - a.similarity)
})

// 计算颜色相似度
const calculateColorSimilarity = (color1, color2) => {
  // 简单的色相相似度计算
  const hueDiff = Math.abs(color1.hue - color2.hue)
  return Math.max(0, 100 - hueDiff / 3.6)
}

// 选择相似颜色
const selectSimilarColor = (color) => {
  const index = extractedColors.value.findIndex(c => c.hex === color.hex)
  selectedColorIndex.value = index
}

// 主色调（前3个颜色）
const mainColors = computed(() => extractedColors.value.slice(0, 3))

// 辅助色（中间3个颜色）
const accentColors = computed(() => {
  const mid = Math.floor(extractedColors.value.length / 2)
  return extractedColors.value.slice(mid, mid + 3)
})

// 中性色（饱和度较低的颜色）
const neutralColors = computed(() =>
  extractedColors.value
    .filter(color => color.saturation < 30)
    .slice(0, 3)
)

// 复制单个颜色
const copyColor = async (color) => {
  const textToCopy = `${color.hex} - RGB: ${color.rgb.r}, ${color.rgb.g}, ${color.rgb.b}`

  try {
    await navigator.clipboard.writeText(textToCopy)
    copyButtonText.value = '已复制!'
    setTimeout(() => {
      copyButtonText.value = '复制所有颜色'
    }, 2000)
  } catch (err) {
    // 降级方案
    const textArea = document.createElement('textarea')
    textArea.value = textToCopy
    document.body.appendChild(textArea)
    textArea.select()
    document.execCommand('copy')
    document.body.removeChild(textArea)
    copyButtonText.value = '已复制!'
    setTimeout(() => {
      copyButtonText.value = '复制所有颜色'
    }, 2000)
  }
}

// 复制所有颜色
const copyAllColors = async () => {
  const colorsText = extractedColors.value.map(color =>
    `${color.hex} (${color.percentage}%)`
  ).join('\n')

  try {
    await navigator.clipboard.writeText(colorsText)
    copyButtonText.value = '已复制所有颜色!'
    setTimeout(() => {
      copyButtonText.value = '复制所有颜色'
    }, 2000)
  } catch (err) {
    const textArea = document.createElement('textarea')
    textArea.value = colorsText
    document.body.appendChild(textArea)
    textArea.select()
    document.execCommand('copy')
    document.body.removeChild(textArea)
    copyButtonText.value = '已复制所有颜色!'
    setTimeout(() => {
      copyButtonText.value = '复制所有颜色'
    }, 2000)
  }
}

// 导出调色板
const exportPalette = () => {
  const paletteData = {
    colors: extractedColors.value,
    extractedAt: new Date().toISOString(),
    options: extractOptions.value
  }

  const blob = new Blob([JSON.stringify(paletteData, null, 2)], {
    type: 'application/json'
  })
  const url = URL.createObjectURL(blob)
  const link = document.createElement('a')
  link.download = `palette-${Date.now()}.json`
  link.href = url
  link.click()
  URL.revokeObjectURL(url)
}

// 生成色阶
const generateShades = () => {
  if (!selectedColor.value) return

  const shades = []
  const baseLightness = selectedColor.value.lightness

  for (let i = -4; i <= 4; i++) {
    const lightness = Math.max(0, Math.min(100, baseLightness + i * 10))
    const hex = hslToHex(selectedColor.value.hue, selectedColor.value.saturation, lightness)
    shades.push({
      hex,
      lightness,
      type: i === 0 ? '基准' : i < 0 ? `变暗${Math.abs(i)}` : `变亮${i}`
    })
  }

  colorShades.value = shades
}

// 分析对比度
const analyzeContrast = () => {
  if (extractedColors.value.length < 2) return
  alert('对比度分析功能开发中...')
}

// 排序颜色
const sortColors = () => {
  extractedColors.value.sort((a, b) => b.lightness - a.lightness)
}

// 保存调色板
const savePalette = () => {
  const savedPalettes = JSON.parse(localStorage.getItem('colorPalettes') || '[]')
  savedPalettes.push({
    name: `调色板 ${new Date().toLocaleDateString()}`,
    colors: extractedColors.value,
    createdAt: new Date().toISOString()
  })
  localStorage.setItem('colorPalettes', JSON.stringify(savedPalettes))
  alert('调色板已保存到本地存储')
}

// 清除图片
const clearImage = () => {
  imagePreview.value = ''
  imageName.value = ''
  extractedColors.value = []
  selectedColorIndex.value = -1
  fileInput.value.value = ''
}

// 监听选项变化，重新提取颜色
watch(extractOptions, () => {
  if (imagePreview.value && extractedColors.value.length > 0) {
    extractColors()
  }
}, { deep: true })

// 监听拖拽状态
watch(isDragover, (newVal) => {
  if (newVal) {
    setTimeout(() => {
      isDragover.value = false
    }, 100)
  }
})
</script>

<style scoped>
.color-extractor {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.tool-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
  border-radius: 12px 12px 0 0;
}

.tool-header h1 {
  margin: 0 0 10px 0;
  font-size: 2.2em;
}

.subtitle {
  margin: 0;
  opacity: 0.9;
  font-size: 1.1em;
}

.tool-content {
  padding: 30px;
}

.upload-section {
  margin-bottom: 30px;
}

.upload-area {
  border: 2px dashed #667eea;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #f8f9ff;
  position: relative;
  overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #764ba2;
  background: #f0f2ff;
  transform: translateY(-2px);
}

.upload-area.has-image {
  padding: 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.preview-image {
  max-width: 200px;
  max-height: 150px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.image-info {
  font-weight: 600;
  color: #333;
  margin: 10px 0;
}

.upload-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 20px;
}

.extract-btn,
.clear-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.extract-btn {
  background: #4caf50;
  color: white;
}

.extract-btn:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-2px);
}

.extract-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.clear-btn {
  background: #ff9800;
  color: white;
}

.clear-btn:hover {
  background: #f57c00;
  transform: translateY(-2px);
}

.options-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.options-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-group label {
  font-weight: 600;
  color: #555;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.count-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
}

.count-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
}

.slider-value {
  font-weight: 600;
  color: #667eea;
  min-width: 60px;
}

select {
  padding: 8px 12px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid #ddd;
  border-radius: 3px;
  position: relative;
  transition: all 0.3s;
}

.checkbox-label input:checked + .checkmark {
  background: #667eea;
  border-color: #667eea;
}

.checkbox-label input:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 12px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.colors-section {
  margin-bottom: 30px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h3 {
  margin: 0;
  color: #333;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.copy-btn,
.export-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.copy-btn {
  background: #2196f3;
  color: white;
}

.export-btn {
  background: #9c27b0;
  color: white;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.colors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
}

.color-item {
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border: 2px solid transparent;
}

.color-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-item.selected {
  border-color: #333;
  transform: scale(1.05);
}

.color-info {
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.color-hex {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 5px;
}

.color-percentage {
  font-size: 12px;
  opacity: 0.9;
}

.color-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.color-format {
  font-size: 11px;
  margin-bottom: 5px;
  opacity: 0.9;
}

.color-actions {
  margin-top: 8px;
}

.color-copy-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.color-detail-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.color-detail-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.detail-content {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 20px;
  align-items: start;
}

.color-preview {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  border: 2px solid #ddd;
}

.color-properties {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.property-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.property {
  display: flex;
  align-items: center;
  gap: 10px;
}

.property-label {
  font-weight: 600;
  color: #666;
  min-width: 60px;
}

.property-value {
  font-family: 'Courier New', monospace;
  background: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.color-similar h4 {
  margin-bottom: 10px;
  color: #333;
}

.similar-colors {
  display: flex;
  gap: 10px;
}

.similar-color {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
  border: 2px solid transparent;
}

.similar-color:hover {
  transform: scale(1.1);
  border-color: #333;
}

.similar-hex {
  color: white;
  font-size: 10px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  font-weight: 600;
}

.palette-tools {
  margin-bottom: 30px;
}

.palette-tools h3 {
  margin-bottom: 15px;
  color: #333;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.tool-item {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  text-align: center;
}

.tool-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 8px;
}

.tool-btn:hover {
  background: #5a6fd8;
}

.suggestions-section {
  margin-bottom: 30px;
}

.suggestions-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.suggestion-item {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
}

.suggestion-title {
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.suggestion-colors {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}

.suggestion-color {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.info-section {
  background: #e3f2fd;
  border-left: 4px solid #2196f3;
  padding: 15px;
  border-radius: 0 8px 8px 0;
}

.info-section h3 {
  color: #1565c0;
  margin-bottom: 10px;
}

.info-section p {
  color: #424242;
  line-height: 1.6;
  margin: 0;
}

.tool-footer {
  text-align: center;
  padding: 20px;
  color: #757575;
  font-size: 14px;
  border-top: 1px solid #e0e0e0;
}

@media (max-width: 768px) {
  .tool-content {
    padding: 20px;
  }

  .upload-actions,
  .header-actions {
    flex-direction: column;
  }

  .options-grid,
  .colors-grid,
  .tools-grid,
  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .detail-content {
    grid-template-columns: 1fr;
  }

  .color-preview {
    width: 100%;
    height: 100px;
  }
}
</style>